﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;
using Yugi.Client.Card;
using System.Threading;


namespace ServerYuGi
{
    public partial class SSupervisor
    {
        void Process_GAME_CHIABAIXONG(params object[] param)
        {
            DemYMSGChiaBaiCuaPlayer++;
            if (DemYMSGChiaBaiCuaPlayer == Players.Count)
            {                
                DrawPhase();                
            }
        }
        public void DrawPhase()
        {
            int IDPlayerRutBai = TurnManager.IDPlayerTrongLuot;
            SPlayer player = LayPlayer(IDPlayerRutBai);
           // GuiYMSGChoTatCaPlayer(YMSG.TURN_DRAWPHASE_BEGIN, IDPlayerRutBai);
            ServerSocket.SendMessageToEveryOne(YMSG.TURN_DRAWPHASE_BEGIN, IDPlayerRutBai);
            int vitrilabai = random.Next(0, player.SoBaiChuaChia.Count);
            SCard tmp = player.SoBaiChuaChia[vitrilabai];            
            tmp.MyYBaseCard.ID = DemID;
            DemID++;
            player.SoBaiTrenTay.Add(tmp);
            player.SoBaiChuaChia.Remove(tmp);
            //Players[IDPlayerRutBai].MySupervisor.ReciveMessageFromServer(YMSG.CARD_RUTBAI, tmp.MyYBaseCard);
            ServerSocket.SendMessageToID(IDPlayerRutBai, YMSG.CARD_RUTBAI,tmp.MyYBaseCard.Card_TypeID, tmp.MyYBaseCard.ID);
        }

        void Process_CARD_RUTBAI_XONG(params object[] param)
        {
            //ServerSocket.SendMessageToEveryOne(YMSG.CARD_RUTBAI_XONG);
            TurnManager.NextTurn();
        }
       
    }
}
